// gui/GuiTextItem.cpp

#include "GuiTextItem.h"

TypeId GUI::GuiTextItem::s_TypeId = "GuiTextItem";

using namespace GUI;

void GuiTextItem::SetupGuiTextItem(wchar_t * pText, FONT::BMFont * pFont)
{
	m_VisualText.SetVisualText(pFont, pText);

	SetVisible(true);
	SetVisual( &m_VisualText );
}

EGuiTextHAlign GuiTextItem::GetHAlign() const
{
	EGuiTextHAlign eAlignments[E_GUITEXTHALIGN_COUNT] =
	{
		E_GUITEXTHALIGN_LEFT,
		E_GUITEXTHALIGN_CENTRE,
		E_GUITEXTHALIGN_RIGHT
	};

	GFX::VisualText::EHAlign eAlignment = m_VisualText.GetHAlign();
	// eAlignment >= 0 && eAlignment <= GFX::VisualText::E_HALIGN_COUNT

	return eAlignments[eAlignment];
}

EGuiTextVAlign GuiTextItem::GetVAlign() const
{
	EGuiTextVAlign eAlignments[E_GUITEXTVALIGN_COUNT] =
	{
		E_GUITEXTVALIGN_TOP,
		E_GUITEXTVALIGN_CENTRE,
		E_GUITEXTVALIGN_BOTTOM,
		E_GUITEXTVALIGN_BASELINE
	};

	GFX::VisualText::EVAlign eAlignment = m_VisualText.GetVAlign();
	// eAlignment >= 0 && eAlignment <= GFX::VisualText::E_VALIGN_COUNT

	return eAlignments[eAlignment];
}

void GuiTextItem::SetAlignment( EGuiTextHAlign eHAlign, EGuiTextVAlign eVAlign)
{
	// eHAlign >= 0 && eHAlign < E_GUITEXTHALIGN_COUNT
	// eVAlign >= 0 && eVAlign < E_GUITEXTVALIGN_COUNT

	GFX::VisualText::EHAlign eHAlignment;
	GFX::VisualText::EVAlign eVAlignment;

	switch (eHAlign)
	{
	case E_GUITEXTHALIGN_LEFT:
		eHAlignment = GFX::VisualText::E_HALIGN_LEFT;
		break;
	case E_GUITEXTHALIGN_CENTRE:
		eHAlignment = GFX::VisualText::E_HALIGN_CENTRE;
		break;
	case E_GUITEXTHALIGN_RIGHT:
		eHAlignment = GFX::VisualText::E_HALIGN_RIGHT;
		break;
	default: // [NOTE} : Error
		break;
	}

	switch (eVAlign)
	{
	case E_GUITEXTVALIGN_TOP:
		eVAlignment = GFX::VisualText::E_VALIGN_TOP;
		break;
	case E_GUITEXTVALIGN_CENTRE:
		eVAlignment = GFX::VisualText::E_VALIGN_CENTRE;
		break;
	case E_GUITEXTVALIGN_BOTTOM:
		eVAlignment = GFX::VisualText::E_VALIGN_BOTTOM;
		break;
	case E_GUITEXTVALIGN_BASELINE:
		break;
	default: // [NOTE] : Error
		break;
	}

	m_VisualText.SetAlignment( eHAlignment, eVAlignment );
}